package com.doudou.collection.service.impl;

import com.doudou.collection.mapper.BlogCategoriesMapper;
import com.doudou.collection.pojo.dto.BlogCategoriesDTO;
import com.doudou.collection.pojo.entity.BlogCategories;
import com.doudou.collection.pojo.vo.BlogCategoriesVO;
import com.doudou.collection.response.ResultVO;
import com.doudou.collection.service.BlogCategoriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class BlogCategoriesServiceImpl implements BlogCategoriesService {
    @Autowired
    BlogCategoriesMapper blogCategoriesMapper;
    @Override
    public ResultVO insertForBlogCategories(BlogCategoriesDTO blogCategoriesDTO) {


        BlogCategories blogCategories = new BlogCategories();
        blogCategories.setId(blogCategoriesDTO.getId());
        blogCategories.setName(blogCategoriesDTO.getName());
        blogCategories.setStatus(blogCategoriesDTO.getStatus());
        blogCategories.setCreateTime(new Date());
        blogCategories.setUpdateTime(new Date());
        blogCategoriesMapper.insertForBlogCategories(blogCategories);
        return ResultVO.ok();
    }
    @Override
    public ResultVO deleteForBlogCategories(Long id) {
        blogCategoriesMapper.deleteForBlogCategories(id);
        return ResultVO.ok();
    }

    @Override
    public ResultVO updateForBlogCategories(Long id) {
        blogCategoriesMapper.updateForBlogCategories(id);
        return ResultVO.ok();
    }

    @Override
    public ResultVO selectForBlogCategories() {
        List<BlogCategoriesVO> list = blogCategoriesMapper.selectForBlogCategories();
        return ResultVO.ok(list);
    }
}
